<template>
	<view>
		<view class="inp-line">
			<view class="title">姓名</view>
			<input class="inp" type="text" v-model="user_name" placeholder="输入姓名" />
		</view>
		<view class="inp-line">
			<view class="title">电话</view>
			<input class="inp" type="text" v-model="mobile" placeholder="输入电话" />
		</view>
		<view style="margin-top: 100upx;">
			<button style="width: 90%;background-color: #EA463C;" type="primary" @tap="sub">提交</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				user_name: '',
				mobile: ''
			};
		},
		methods:{
			sub(){
				if(!this.user_name) return;
				if (!this.config.pub.isMobile(this.mobile)) {uni.showToast({title: '请填写正确的手机号',icon: 'none'});return}
				uni.showLoading({title: '加载中',mask: true});
				this.config.post('/api/realname/realName', {
					user_name: this.user_name,
					mobile: this.mobile
				}).then(res=>{
					uni.hideLoading();
					if(res.data.code==='0'){
						uni.showToast({title: res.data.message})
						setTimeout(s=>{
							uni.switchTab({
								url:'/pages/home/home'
							})
						}, 500)
					}else{
						uni.showToast({title: self.config.handleError(res.data),icon: 'none'});
					}
				})
			}
		},
		mounted() {
			uni.showToast({
				title: '请提交您的姓名和电话',
				icon: 'none'
			})
		}
	}
</script>

<style lang="less" scoped>
	.inp-line{
		display: flex;
		padding: 20upx 30upx;
		border-bottom: 1px solid #ccc;
		.title{
			width: 30%;
		}
		.inp{
			width: 70%;
		}
	}
</style>
